package org.aplikator.server.descriptor;

import java.util.Date;

import org.aplikator.client.descriptor.DateFieldDTO;
import org.aplikator.client.descriptor.WidgetDTO;
import org.aplikator.server.Context;

public class DateField implements Widget, HasProperty<Date> {

    private Property<Date> property;

    private boolean labelAbove = true;

    public DateField(Property<Date> property) {
        this.property = property;
    }

    public Property<Date> getProperty() {
        return property;
    }

    public WidgetDTO getWidgetDescriptor(Context ctx) {
        DateFieldDTO desc = new DateFieldDTO(property.clientClone(ctx));
        desc.setLabelAbove(labelAbove);
        return desc;
    }

    public void registerProperties(Form form) {
        form.addProperty(property);
    }

    public boolean isLabelAbove() {
        return labelAbove;
    }

    public DateField setLabelAbove(boolean labelAbove) {
        this.labelAbove = labelAbove;
        return this;
    }
}
